package sale.wxb.loveshopping.scheduled;

import lombok.AllArgsConstructor;
import org.springframework.data.redis.connection.RedisConnectionCommands;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
@AllArgsConstructor
public class RedisPingTask {
    private final StringRedisTemplate stringRedisTemplate;

    // 设置redis每分钟PING一次防止被重置
    @Scheduled(cron = "0 */1 * * * ?")
    public void pingRedisTask() {
        stringRedisTemplate.execute(RedisConnectionCommands::ping);
    }
}
